﻿using Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RegisterServer
{
    public partial class RegisterForm : Form
    {
        public RegisterForm()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 注册机事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCreateRCode_Click(object sender, EventArgs e)
        {
            try
            {
                //获取客户端信息，解密？
                string strDes = DataEncrypt.DESDecrypt(this.txtKey.Text.Trim());
                string nowDate = strDes.Split(',')[0];
                string cpuID = strDes.Split(',')[1];
                if (nowDate == DateTime.Now.ToString("yyyyMMdd"))//注册码是否是今天
                {
                    string endDate = this.dtpDate.Value.ToString("yyyyMMdd");//授权日期
                    string email = this.txtEmail.Text.Trim();
                    string phone = this.txtPhone.Text.Trim();
                    string RCode = $"{endDate},{strDes},{email},{phone}";
                    this.txtRCode.Text = DataEncrypt.DESEncrypt(RCode);
                }
                else
                {
                    MessageBox.Show("你的日期可能被篡改");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("秘钥有误，请检查!");
            }


        }
    }
}
